package com.itheima.d1_string;

public class StringBuilderDemo2 {
    public static void main(String[] args) {
        String str = getArrayData(new int[]{11,22,33});
        System.out.println(str);
    }

    private static String getArrayData(int[] arr) {
        //判断数组是否为空
        if(arr == null){
            return null;
        }

        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < arr.length; i++) {
            if(i == arr.length - 1 ) {
                sb.append(arr[i]).append("]");
            }else{
                sb.append(arr[i]).append(",");
            }
        }
        return sb.toString();
    }
}
